#!/usr/bin/env bash
#
# Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
#
# GreenCode is licensed under the Apache License, Version 2.0
#  (the "License"); you may not use this file except in compliance
#  with the License.  Date : 2025.10.28
#
#  History : Initial Version 2025.10.28
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES
# OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the License for the specific language governing permissions and
# limitations under the License.
#

gcc_req="5.1"
python_req="3.6.1"

. ./setenv.bash

pause() {
    echo
    read -r -sn1 -p "$1 -- Press Enter to continue or Ctrl-C to quit"
    echo
}

gcc_ver=$(g++ --version|grep g++|awk '{print $NF}')
if ! ( ./version_chk.py "$gcc_ver" "$gcc_req" ); then
  echo g++ version needs to be >= "$gcc_req"
  pause "g++ version may need updating."
fi

python_ver=$(python3 --version|grep Python|awk '{print $NF}')
if ! ( ./version_chk.py "$python_ver" "$python_req" ); then
  echo python version needs to be >= "$python_req"
  pause "python version may need updating."
fi

echo Current environment:
echo GREEN_CC="$GREEN_CC"
echo GREEN_PYTHON_VER="$GREEN_PYTHON_VER"
echo GREEN_PYTHON_INC="$GREEN_PYTHON_INC"
echo GREEN_PYTHON_LIB="$GREEN_PYTHON_LIB"

make -j
make -j tests
./utils/regression/master_run.py
./utils/regression/unit_tests.py

